package com.kt.uokos.yimo.controller;

import com.kt.uokos.yimo.anno.validator.Order;
import com.kt.uokos.yimo.anno.validator.Sort;
import com.kt.uokos.yimo.dao.AdminAddress;
import com.kt.uokos.yimo.service.AdminAddressService;
import com.kt.uokos.yimo.util.ResponseUtil;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin/address")
public class AdminAddressController {

    @Resource
    private AdminAddressService adminAddressService;

    @GetMapping("/list")
    public Object list( Integer userId, String name,
                        @RequestParam(defaultValue = "1") Integer page,
                        @RequestParam(defaultValue = "10") Integer limit,
                        @Sort @RequestParam(defaultValue = "add_time") String sort,
                        @Order @RequestParam(defaultValue = "desc") String order) {

        List<AdminAddress> addressList = adminAddressService.querySelective(userId, name, page, limit, sort, order);
        return ResponseUtil.okList(addressList);
    }
}
